package com.aaa.project1;

import org.junit.Test;

public class Meth {
    /*排序*/
    public static void sort(int [] arr){
        int l = arr.length;
        for (int i = 0; i < l ; i++) {
            for (int j = 0; j < l-1 ; j++) {
                if (arr[j]>arr[j+1]) {
                    int temp =arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=temp;
                }
            }
        }
    }
    /*最大值*/
    public static  int Max(int  [] arr){
        int temp =arr[0];
        for (int i = 0; i <arr.length ; i++) {
            if (temp<arr[i]) {
                temp=arr[i];
            }
        }
        return temp;
    }
    /*索引*/
    public static  int indexOf(int [] arr,int a){
        for (int i = 0; i < arr.length ; i++) {
            if (a==arr[i]) {
                return i;
            }
        }
        return -1;
    }
    /*拼接字符串*/
    public  static  String MyString(int [] arr){
        String str ="[";
        for (int i = 0; i < arr.length ; i++) {
            str+=arr[i];
            if (i< arr.length-1) {
                str+=",";
            }else {
                str+="]";
            }
        }
        return str;
    }
    /*字符串是 否一致*/
    public static String yizhi (int[]arr,int []arr1){
        if (arr.length!=arr1.length) {
            return "不一致";
        }
        for (int i = 0; i < arr.length ; i++) {
            if (arr[i]!=arr1[i]) {
                return "不一致";
            }
        }
        return "一致";
    }
}
